//MultiWorldMode

var path="./plugins/MultiWorldMode/";
var worlds=manager.getFolderFiles("./worlds");

function PluginEnableEvent(evt)
{
    if(manager.readFile(path+"config.json")==="FILE NOT FOUND")
    {
        logger.warning("配置文件不存在，重新建立！");
        let config={};
        for(let i=0;i<worlds.length;i++)
            config[worlds[i]]="survival";
        manager.writeFile(path+"config.json",JSON.stringify(config));
    }
    if(worlds.length!==0)
        logger.info("MultiWorldMode已成功加载！");
    else
        logger.warning("worlds文件夹下没有文件，MultiWorldMode加载失败！");
}

function PlayerTeleportEvent(evt)
{
    let player=evt.getPlayer()
    let des=evt.getTo().getLevel().getName();
    let desMode=JSON.parse(manager.readFile(path+"config.json"))[des];
    if(desMode==="creative")
        player.setGamemode(1);
    else
    {
        player.setGamemode(0);
        logger.info(desMode);
    }
        
    }